package com.zzzs; /**
 *  HostScannerFX.java
 *  @author Charzous
 *  @date 2021-05-30 下午 07:03
 *  Copyright (c) 2020-10-30
 *  All right reserved.
 *
 */
 
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
 
public class HostScannerFX extends Application {
    private TextArea result = new TextArea();
    private TextField begin = new TextField();
    private TextField end = new TextField();
    private TextField tfCmd = new TextField();
    private Button PCScan = new Button("主机扫描");
    private Button stop=new Button("停止");
    private Button exeCmd = new Button("执行命令");
    private Thread readThread;
 
    @Override
    public void start(Stage primaryStage) throws Exception {
        BorderPane mainPane = new BorderPane();
        VBox vBox = new VBox();
        vBox.setSpacing(10);
        vBox.setPadding(new Insets(10, 20, 10, 20));
        VBox.setVgrow(result, Priority.ALWAYS);
        vBox.getChildren().addAll(new Label("扫描结果："), result);
        mainPane.setCenter(vBox);
 
        HBox hBox1 = new HBox();
        hBox1.setSpacing(10);
        hBox1.setPadding(new Insets(10, 20, 10, 20));
        hBox1.setAlignment(Pos.CENTER);
        begin.setPrefWidth(180);
        end.setPrefWidth(180);
        hBox1.getChildren().addAll(new Label("起始地址："), begin, new Label("结束地址："), end, PCScan,stop);
 
        HBox hBox2 = new HBox();
        hBox2.setSpacing(10);
        hBox2.setPadding(new Insets(10, 20, 10, 20));
        hBox2.setAlignment(Pos.CENTER);
        HBox.setHgrow(tfCmd, Priority.ALWAYS);
        hBox2.getChildren().addAll(new Label("输入命令格式："), tfCmd, exeCmd);
 
        VBox vBox1 = new VBox();
        vBox1.setSpacing(10);
        vBox1.setPadding(new Insets(10, 20, 10, 20));
        vBox1.setAlignment(Pos.CENTER);
        vBox1.getChildren().addAll(hBox1, hBox2);
        mainPane.setBottom(vBox1);
 
        Scene scene = new Scene(mainPane, 800, 500);
        primaryStage.setScene(scene);
        primaryStage.setTitle("MyHostScanner");
        primaryStage.show();
        
        //关闭窗口
        primaryStage.setOnCloseRequest(event -> {
            System.exit(0);
        });
    }
}